module.exports = (options) => {
	const uniID = require('uni-id')
	const uniCaptcha = require('uni-captcha')
	// 返回中间件函数
	return async function user(ctx, next) {
		const {event} = ctx
		const uni_id = uniID.createInstance({
			context:ctx 
		})
		if(!ctx.event.token){
			throw {
				code:201,
				message:'token 不存在或已过期'
			};
		}
		let res = await uni_id.checkToken(ctx.event.token);
		if(res.code !== 0) {
			throw res;
		}
		await next();
	};
};
